const webpack = require('webpack');
const path = require('path')

function resolve(dir) {
    return path.join(__dirname, dir)
}

module.exports = {
    lintOnSave: false,
    devServer: {
        historyApiFallback: true,
        hot: true,  // 自动加载
        watchFiles: {
          paths: ['src/**/*'],
          options: {
            usePolling: true,
            ignored: /node_modules/
          }
        }
    },

    // webpack 配置
    chainWebpack(config) {
        // 设置 svg-sprite-loader
        config.module
            .rule('svg')
            .exclude.add(resolve('src/icons'))
            .end()
        
        config.module
            .rule('icons')
            .test(/\.svg$/)
            .include.add(resolve('src/icons'))
            .end()
            .use('svg-sprite-loader')
            .loader('svg-sprite-loader')
            .options({
                symbolId: '[name]'  // 修改这里，移除 icon- 前缀
            })
            .end()

        // 添加Vue特性标志定义
        config
            .plugin('define')
            .tap(args => {
                args[0].__VUE_PROD_HYDRATION_MISMATCH_DETAILS__ = false
                return args
            })
    }
}
